/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.hutech09.jsale.web.manager.users;

import java.util.List;
import javax.faces.model.ListDataModel;
import org.hutech09.jsale.entity.AccessUser;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author Nam
 */
public class UserDataModel extends ListDataModel<AccessUser> implements SelectableDataModel<AccessUser> {

    public UserDataModel() {
    }

    public UserDataModel(List<AccessUser> list) {
        super(list);
    }

    @Override
    public Object getRowKey(AccessUser t) {
        return t.getId();
    }

    @Override
    public AccessUser getRowData(String rowKey) {
        List<AccessUser> users = (List<AccessUser>) getWrappedData();
        for (AccessUser user : users) {
            if (user.getId().equals(rowKey)) {
                return user;
            }
        }
        return null;
    }
}
